package com.ruoyi.web.xxj.contoller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.xxj.domain.pojo.WeChatReq;
import com.ruoyi.web.xxj.service.IWxloginService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@Api(tags = "微信小程序登录")
@RestController
@RequestMapping("/xxj/wx")
public class WxloginController extends BaseController {

    @Autowired
    private IWxloginService wxloginService;

    @ApiOperation("小程序登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestBody WeChatReq weChatReq) {
        return wxloginService.wxLogin(weChatReq);
    }
    
    @ApiOperation("获取用户手机号")
    @PostMapping("/getPhoneNo")
    public AjaxResult getPhoneNo(@RequestBody String code) {
    	JSONObject paramsJSONObject = JSONObject.parseObject(code);
    	return wxloginService.getPhoneNo(paramsJSONObject.getString("code"));
    }
}
